<?php

use Doraemon\cache\Follow;
use Doraemon\service\UserFlow\Flow;
use Doraemon\tools\ActionLog;

/**
 * 用户的关注用户集合
 */
class FollowUserAction extends ActionPlugin
{
    public function main()
    {
        \Doraemon\tools\Log::info('关注用户', $this->messageBody);
        $iUid = $this->messageBody['data']['uid'] ?? 0;
        $type = $this->messageBody['type'];
        $aData = $this->messageBody['data'];

        if (!$iUid) {
            throw new \Exception('数据错误！');
        }
        //取消关注
        if('update' == $type && 9 == $aData['status']){
            Follow::delFollow($iUid,$aData['befollowed_uid']);

        }else{
            //关注
            Follow::setFollow($iUid,$aData['befollowed_uid']);
        }
        $this->setSuccess();
    }
}
